/**
 * test case for api_user
 */
describe("api_user", function() {
    beforeEach(function() {
        App.initSession();
    });

    describe('bsoi login', function() {
        var callback = jasmine.createSpy();
        var userName = 'inuser001', password = 'ibnk1357', cpach = null;
        beforeEach(function() {
            spyOn(bsoi, "login");
        });

        it('User can login with user name & password', function() {
            spyOn(App.api_user, "_processLogin");

            App.api_user.login(userName, password, cpach, false, callback);
            userName = userName.toUpperCase();
            expect(App.api_user.callbackLogin).toEqual(callback);

            var t_session = App.getSession();
            expect(t_session.getBreezeContext().userContext.userId).toEqual(
                userName);
            expect(bsoi.login).toHaveBeenCalled();

            var callArgs = bsoi.login.mostRecentCall.args;
            var response = jasmine.createSpy();
            callArgs[1](response);

            expect(App.api_user._processLogin).toHaveBeenCalledWith(response);
        });
    });
});